#ifndef __LGUILISTBOX_H__
#define __LGUILISTBOX_H__

#include "LString.h"
#include "LGUIVSlider.h"
#include "LGUIContainer.h"

class LGUIListBox : public LGUIContainer
{
  LGUIVSlider *slider;
  struct LItem {
    String text;
  };

  int numItems;
  int maxItems;

  int topItem;
  int itemHeight;  
  int selectedItem;
  
protected:
  LItem *items;
  virtual void onClick(int n) { }
public:
	LGUIListBox(int id, int _x, int _y, int _w, int _h);
  void addItem(const TCHAR *txt);
  static int compare(const void *i1, const void *i2);
  void sort();
  void deleteItem(int i);
  void moveUp(int i);
  void moveDown(int i);
  virtual void draw(int xoff, int yoff);
  virtual void penDown(int px, int py);
  virtual int getNumItems() {
    return numItems;
  }
  virtual int getSelectedItem()
  {
    return selectedItem;
  }
  virtual int getVisibleItems()
  {
    return (h-2)/itemHeight;
  }
  void makeRoom(int _num)
  {
    maxItems = _num;
    delete [] items;
    items=new LItem[_num];
    numItems=0;
  }
  void clear()
  {
    numItems=0;
    selectedItem=0;
    topItem=0;
  }
  virtual void scrollTo(int _i)
  {
    topItem=_i;
    redraw();
  }
	virtual ~LGUIListBox();
  virtual void deliverMessage(LGUIMessage &msg);
};


#endif //__LGUILISTBOX_H__